# 服务器名
server_name=bird02
# 应用名
application_name=bird02
# 本地的jar名
local_jar_name=jeecg-system-start-3.4.4.jar
# 服务器部署目录
remote_deploy_dir=/root/jar/
# 启动脚本名
start_sh_file_name=pig-restart-80.sh

# 1. 上传启动脚本
remote_start_sh_file_path=$remote_deploy_dir$start_sh_file_name
ssh $server_name 'mkdir -p '$remote_deploy_dir
result=$(ssh $server_name "[ -e "$remote_start_sh_file_path" ] && echo '文件存在' || echo '文件不存在'")
if [ "$result" != "文件存在" ]; then
  echo '上传启动脚本...'
  scp ./$start_sh_file_name root@$server_name:$remote_deploy_dir
fi

## 2. 上传jar包
echo  '上传jar包...'
scp ./target/$local_jar_name root@$server_name:$remote_deploy_dir$application_name.jar
## 3. 启动脚本
ssh $server_name 'cd '$remote_deploy_dir' &&sh '$start_sh_file_name $application_name $remote_deploy_dir
